import java.util.Arrays;

public class Solution {
    public static void main(String[] args) {
        int[] A = {1,2,3,4};
        int[] B = {5,6,7,8};

    }
    public int[] M(int[] A,int[] B){
        int i,j,k;
        int[] arr = new int[A.length+B.length];
        while (i<A.length&&j<B.length){
            if(A[i]<B[j]) {
                arr[k] = A[i++];
                else
                arr[k] = B[j++];
                k++;
            }
            while (i < A.length) {
                arr[k]=A[i++];
                k++;
            }
            while (j < B.length) {
                arr[k]=B[j++];
                k++;
        }
            return arr;
    }




